/*************************************
	字段检查
	@param inputConfig 输入配置
	@param inputCompent 输入组件
*************************************/
function checkTextField(inputConfig,inputCompent){
	if(undefined == inputConfig && undefined == inputCompent){
		return ;
	}
	var id	=	inputCompent.attr("id");
	if(undefined == id || id.indexOf("info")!=0){
		return true;
	}
	var tip		=	inputConfig.tip;
	if(undefined == tip || "" == tip){
		tip	=	inputConfig.inputTitle+"不符合规范";
	}
	var value	=	inputCompent.val();
	//输入不能为空
	if(inputConfig.min > 0){
		if("" == value || value.length < inputConfig.min){
			alert(tip);
			return false;
		}
	}
	
	if(inputConfig.max > 0){
		if("" != value && value.length > inputConfig.max){
			alert(tip);
			return false;
		}
	}
	
	var pattern	=	inputConfig.pattern;
	if(undefined != pattern && "" != pattern){
		if(false == eval(pattern).test(value)){
			alert(tip);
			return false;
		}
	}
	return inputCompent.val();
}


//附件检测
function checkFJField(inputConfig,inputCompent){
	if(undefined == inputConfig && undefined == inputCompent){
		return ;
	}
	
	return inputCompent.val();
}

/*************************************
	复选字段检查
	@param inputConfig 输入配置
	@param inputCompent 输入组件
*************************************/
function checkCheckField(inputConfig,inputCompent){
	if(undefined == inputConfig && undefined == inputCompent){
		return ;
	}
	
	if(1 != inputConfig.canNull){
		
	}
	var tip		=	inputConfig.tip;
	if(undefined == tip || "" == tip){
		tip	=	inputConfig.inputTitle+"不符合规范";
	}
	
	//输入不能为空
	
	var items = $('.'+inputConfig.field);
	if(items.length == 0){
		alert(tip);
		return false;
	}else{
		var total	=	0;
		var value	=	"";
		for(var x=0;x<items.length;x++){
			var checked	=	$(items[x]).attr("checked");
			if(true == checked || "checked" == checked){
				value	=	$(items[x]).val();	
				total++;
			}
		}
		if(0 == total && 1== inputConfig.canNull){
			alert(tip);
			return false;
		}
		return value;
	}
	
}

function checkRadioField(inputConfig,inputCompent){
	return inputCompent.val();
}

//下拉框验证
function checkSelectField(inputConfig,inputCompent){
	
	if(undefined == inputConfig && undefined == inputCompent){
		return ;
	}
	
	var tip		=	inputConfig.tip;
	if(undefined == tip || "" == tip){
		tip	=	inputConfig.inputTitle+"不符合规范";
	}
	
	//输入不能为空
	
	var value	=	inputCompent.val();
	if("" == value && 1== inputConfig.canNull){
		alert(tip);
		return false;
	}
	
	return inputCompent.val();
}

//下拉框验证
function checkDateField(inputConfig,inputCompent){
	
	if(undefined == inputConfig && undefined == inputCompent){
		return ;
	}
	
	var tip		=	inputConfig.tip;
	if(undefined == tip || "" == tip){
		tip	=	inputConfig.inputTitle+"不符合规范";
	}
	
	//输入不能为空
	
	var value	=	inputCompent.datebox("getValue");
	if("" == value && 1 != inputConfig.canNull){
		alert(tip);
		return false;
	}
	
	return value;
}

//下拉框验证
function checkTimeField(inputConfig,inputCompent){
	
	if(undefined == inputConfig && undefined == inputCompent){
		return ;
	}
	
	var tip		=	inputConfig.tip;
	if(undefined == tip || "" == tip){
		tip	=	inputConfig.inputTitle+"不符合规范";
	}
	
	//输入不能为空
	
	var value	=	inputCompent.datetimebox("getValue");
	if("" == value && 1 != inputConfig.canNull){
		alert(tip);
		return false;
	}
	
	return value;
}

//下拉框验证
function checkComTreeField(inputConfig,inputCompent){
	
	if(undefined == inputConfig && undefined == inputCompent){
		return "";
	}
	
	var tip		=	inputConfig.tip;
	if(undefined == tip || "" == tip){
		tip	=	inputConfig.inputTitle+"不符合规范";
	}
	
	//输入不能为空
	
	if(undefined != inputConfig.querySql && undefined != inputConfig.codeField && 
			undefined != inputConfig.titleField && undefined != inputConfig.parentField){
		var value	=	inputCompent.combotree("getValue");
		if("" == value && 1 == inputConfig.canNull){
			alert(tip);
			return false;
		}
		
		return value;
	}
	return "";
}